﻿CREATE DATABASE Jobs
GO

USE [Jobs]
GO
/****** Object:  Table [dbo].[Person]    Script Date: 06/12/2012 17:46:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Person]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Person](
	[PersonId] [int] IDENTITY(1,1) NOT NULL,
	[FullName] [nvarchar](50) NOT NULL,
	[RegisterTime] [datetime] NOT NULL,
	[LastLoginTime] [datetime] NULL,
	[Email] [nvarchar](50) NULL,
	[Mobile] [varchar](11) NULL,
 CONSTRAINT [PK_Person] PRIMARY KEY CLUSTERED 
(
	[PersonId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
SET IDENTITY_INSERT [dbo].[Person] ON
INSERT [dbo].[Person] ([PersonId], [FullName], [RegisterTime], [LastLoginTime], [Email], [Mobile]) VALUES (1, N'王普', CAST(0x0000A06E0120B8A6 AS DateTime), NULL, N'wlmzfx@gmail.com', N'')
INSERT [dbo].[Person] ([PersonId], [FullName], [RegisterTime], [LastLoginTime], [Email], [Mobile]) VALUES (2, N'艾榕', CAST(0x0000A06E0121F61B AS DateTime), NULL, N'admin@irongs.com', N'')
INSERT [dbo].[Person] ([PersonId], [FullName], [RegisterTime], [LastLoginTime], [Email], [Mobile]) VALUES (3, N'测试用户', CAST(0x0000A06E012427C5 AS DateTime), NULL, N'wlmzfx@11.com', N'')
SET IDENTITY_INSERT [dbo].[Person] OFF
/****** Object:  Table [dbo].[Person_JobSeeker]    Script Date: 06/12/2012 17:46:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Person_JobSeeker]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Person_JobSeeker](
	[JobSeekerId] [int] IDENTITY(1,1) NOT NULL,
	[Education] [nvarchar](50) NULL,
	[PersonId] [int] NOT NULL,
 CONSTRAINT [PK_Person_JobSeeker] PRIMARY KEY CLUSTERED 
(
	[PersonId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[Person_JobSeeker] ON
INSERT [dbo].[Person_JobSeeker] ([JobSeekerId], [Education], [PersonId]) VALUES (1, N'Master', 1)
INSERT [dbo].[Person_JobSeeker] ([JobSeekerId], [Education], [PersonId]) VALUES (2, N'Master', 3)
SET IDENTITY_INSERT [dbo].[Person_JobSeeker] OFF
/****** Object:  Table [dbo].[Person_Company]    Script Date: 06/12/2012 17:46:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Person_Company]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Person_Company](
	[CompanyId] [int] IDENTITY(1,1) NOT NULL,
	[Address] [nvarchar](100) NULL,
	[PersonId] [int] NOT NULL,
 CONSTRAINT [PK_Person_Company] PRIMARY KEY CLUSTERED 
(
	[PersonId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[Person_Company] ON
INSERT [dbo].[Person_Company] ([CompanyId], [Address], [PersonId]) VALUES (1, N'company Address', 2)
SET IDENTITY_INSERT [dbo].[Person_Company] OFF
/****** Object:  Table [dbo].[Security]    Script Date: 06/12/2012 17:46:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Security]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Security](
	[Username] [nvarchar](50) NOT NULL,
	[Password] [nvarchar](50) NOT NULL,
	[PersonId] [int] NOT NULL,
 CONSTRAINT [PK_Security] PRIMARY KEY CLUSTERED 
(
	[Username] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
INSERT [dbo].[Security] ([Username], [Password], [PersonId]) VALUES (N'irongs', N'2d57d0299e4ea2dd9d3cb38f6426dbd5', 2)
INSERT [dbo].[Security] ([Username], [Password], [PersonId]) VALUES (N'wlmzfx', N'2d57d0299e4ea2dd9d3cb38f6426dbd5', 1)
INSERT [dbo].[Security] ([Username], [Password], [PersonId]) VALUES (N'wlmzfx2', N'e10adc3949ba59abbe56e057f20f883e', 3)
/****** Object:  Table [dbo].[Resume]    Script Date: 06/12/2012 17:46:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Resume]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Resume](
	[ResumeId] [int] IDENTITY(1,1) NOT NULL,
	[JobSeekerId] [int] NOT NULL,
	[FullName] [nvarchar](5) NOT NULL,
	[Age] [int] NOT NULL,
	[Gender] [int] NOT NULL,
 CONSTRAINT [PK_Resume] PRIMARY KEY CLUSTERED 
(
	[ResumeId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[Jobs]    Script Date: 06/12/2012 17:46:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Jobs]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Jobs](
	[JobId] [int] IDENTITY(1,1) NOT NULL,
	[Title] [nvarchar](50) NOT NULL,
	[Description] [nvarchar](max) NOT NULL,
	[ContactEmail] [nvarchar](100) NOT NULL,
	[ContactPhone] [varchar](11) NOT NULL,
	[StartTime] [datetime] NOT NULL,
	[EndTime] [datetime] NULL,
	[CompanyId] [nvarchar](max) NOT NULL,
	[Company_PersonId] [int] NOT NULL,
 CONSTRAINT [PK_Jobs] PRIMARY KEY CLUSTERED 
(
	[JobId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
SET IDENTITY_INSERT [dbo].[Jobs] ON
INSERT [dbo].[Jobs] ([JobId], [Title], [Description], [ContactEmail], [ContactPhone], [StartTime], [EndTime], [CompanyId], [Company_PersonId]) VALUES (2, N'软件开发工程师', N'软件开发工程师', N'hr@aa.com', N'12345678910', CAST(0x0000A07000000000 AS DateTime), CAST(0x0000A08000000000 AS DateTime), N'1', 2)
INSERT [dbo].[Jobs] ([JobId], [Title], [Description], [ContactEmail], [ContactPhone], [StartTime], [EndTime], [CompanyId], [Company_PersonId]) VALUES (3, N'软件测试工程师', N'软件开发工程师', N'hr@aa.com', N'12345678910', CAST(0x0000A07000000000 AS DateTime), CAST(0x0000A08000000000 AS DateTime), N'1', 2)
INSERT [dbo].[Jobs] ([JobId], [Title], [Description], [ContactEmail], [ContactPhone], [StartTime], [EndTime], [CompanyId], [Company_PersonId]) VALUES (4, N'系统架构师', N'软件开发工程师', N'hr@aa.com', N'12345678910', CAST(0x0000A07000000000 AS DateTime), CAST(0x0000A08000000000 AS DateTime), N'1', 2)
INSERT [dbo].[Jobs] ([JobId], [Title], [Description], [ContactEmail], [ContactPhone], [StartTime], [EndTime], [CompanyId], [Company_PersonId]) VALUES (5, N'项目经理', N'软件开发工程师', N'hr@aa.com', N'12345678910', CAST(0x0000A07000000000 AS DateTime), CAST(0x0000A08000000000 AS DateTime), N'1', 2)
INSERT [dbo].[Jobs] ([JobId], [Title], [Description], [ContactEmail], [ContactPhone], [StartTime], [EndTime], [CompanyId], [Company_PersonId]) VALUES (6, N'产品经理助理', N'软件开发工程师', N'hr@aa.com', N'12345678910', CAST(0x0000A07000000000 AS DateTime), CAST(0x0000A08000000000 AS DateTime), N'1', 2)
INSERT [dbo].[Jobs] ([JobId], [Title], [Description], [ContactEmail], [ContactPhone], [StartTime], [EndTime], [CompanyId], [Company_PersonId]) VALUES (7, N'项目经理助理', N'软件开发工程师', N'hr@aa.com', N'12345678910', CAST(0x0000A07000000000 AS DateTime), CAST(0x0000A08000000000 AS DateTime), N'1', 2)
INSERT [dbo].[Jobs] ([JobId], [Title], [Description], [ContactEmail], [ContactPhone], [StartTime], [EndTime], [CompanyId], [Company_PersonId]) VALUES (8, N'C#开发工程师', N'软件开发工程师', N'hr@aa.com', N'12345678910', CAST(0x0000A07000000000 AS DateTime), CAST(0x0000A08000000000 AS DateTime), N'1', 2)
INSERT [dbo].[Jobs] ([JobId], [Title], [Description], [ContactEmail], [ContactPhone], [StartTime], [EndTime], [CompanyId], [Company_PersonId]) VALUES (9, N'Java开发工程师', N'软件开发工程师', N'hr@aa.com', N'12345678910', CAST(0x0000A07000000000 AS DateTime), CAST(0x0000A08000000000 AS DateTime), N'1', 2)
INSERT [dbo].[Jobs] ([JobId], [Title], [Description], [ContactEmail], [ContactPhone], [StartTime], [EndTime], [CompanyId], [Company_PersonId]) VALUES (10, N'高级培训工程师', N'软件开发工程师', N'hr@aa.com', N'12345678910', CAST(0x0000A07000000000 AS DateTime), CAST(0x0000A08000000000 AS DateTime), N'1', 2)
INSERT [dbo].[Jobs] ([JobId], [Title], [Description], [ContactEmail], [ContactPhone], [StartTime], [EndTime], [CompanyId], [Company_PersonId]) VALUES (11, N'软件开发工程师', N'软件开发工程师', N'hr@aa.com', N'12345678910', CAST(0x0000A07000000000 AS DateTime), CAST(0x0000A08000000000 AS DateTime), N'1', 2)
SET IDENTITY_INSERT [dbo].[Jobs] OFF
/****** Object:  Table [dbo].[JobsResume]    Script Date: 06/12/2012 17:46:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[JobsResume]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[JobsResume](
	[JobId] [int] NOT NULL,
	[ResumeId] [int] NOT NULL,
	[AppliedTime] [datetime] NOT NULL,
	[IsRead] [bit] NOT NULL,
 CONSTRAINT [PK_JobsResume] PRIMARY KEY CLUSTERED 
(
	[JobId] ASC,
	[ResumeId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[Experience]    Script Date: 06/12/2012 17:46:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Experience]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Experience](
	[ExperienceId] [int] IDENTITY(1,1) NOT NULL,
	[ResumeId] [int] NOT NULL,
	[FullName] [nvarchar](50) NOT NULL,
	[StartTime] [datetime] NOT NULL,
	[EndTime] [datetime] NULL,
	[Description] [nvarchar](500) NOT NULL,
	[AtCompany] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_Experience] PRIMARY KEY CLUSTERED 
(
	[ExperienceId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[Education]    Script Date: 06/12/2012 17:46:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Education]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Education](
	[EducationId] [int] IDENTITY(1,1) NOT NULL,
	[ResumeId] [int] NOT NULL,
	[FullName] [nvarchar](50) NOT NULL,
	[StartTime] [datetime] NOT NULL,
	[EndTime] [datetime] NULL,
	[Description] [nvarchar](200) NULL,
 CONSTRAINT [PK_Education] PRIMARY KEY CLUSTERED 
(
	[EducationId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  ForeignKey [FK_Education_Resume]    Script Date: 06/12/2012 17:46:21 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Education_Resume]') AND parent_object_id = OBJECT_ID(N'[dbo].[Education]'))
ALTER TABLE [dbo].[Education]  WITH CHECK ADD  CONSTRAINT [FK_Education_Resume] FOREIGN KEY([ResumeId])
REFERENCES [dbo].[Resume] ([ResumeId])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Education_Resume]') AND parent_object_id = OBJECT_ID(N'[dbo].[Education]'))
ALTER TABLE [dbo].[Education] CHECK CONSTRAINT [FK_Education_Resume]
GO
/****** Object:  ForeignKey [FK_Experience_Resume]    Script Date: 06/12/2012 17:46:21 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Experience_Resume]') AND parent_object_id = OBJECT_ID(N'[dbo].[Experience]'))
ALTER TABLE [dbo].[Experience]  WITH CHECK ADD  CONSTRAINT [FK_Experience_Resume] FOREIGN KEY([ResumeId])
REFERENCES [dbo].[Resume] ([ResumeId])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Experience_Resume]') AND parent_object_id = OBJECT_ID(N'[dbo].[Experience]'))
ALTER TABLE [dbo].[Experience] CHECK CONSTRAINT [FK_Experience_Resume]
GO
/****** Object:  ForeignKey [FK_CompanyJobs]    Script Date: 06/12/2012 17:46:21 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CompanyJobs]') AND parent_object_id = OBJECT_ID(N'[dbo].[Jobs]'))
ALTER TABLE [dbo].[Jobs]  WITH CHECK ADD  CONSTRAINT [FK_CompanyJobs] FOREIGN KEY([Company_PersonId])
REFERENCES [dbo].[Person_Company] ([PersonId])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CompanyJobs]') AND parent_object_id = OBJECT_ID(N'[dbo].[Jobs]'))
ALTER TABLE [dbo].[Jobs] CHECK CONSTRAINT [FK_CompanyJobs]
GO
/****** Object:  ForeignKey [FK_JobsResume_Jobs]    Script Date: 06/12/2012 17:46:21 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_JobsResume_Jobs]') AND parent_object_id = OBJECT_ID(N'[dbo].[JobsResume]'))
ALTER TABLE [dbo].[JobsResume]  WITH CHECK ADD  CONSTRAINT [FK_JobsResume_Jobs] FOREIGN KEY([JobId])
REFERENCES [dbo].[Jobs] ([JobId])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_JobsResume_Jobs]') AND parent_object_id = OBJECT_ID(N'[dbo].[JobsResume]'))
ALTER TABLE [dbo].[JobsResume] CHECK CONSTRAINT [FK_JobsResume_Jobs]
GO
/****** Object:  ForeignKey [FK_JobsResume_Resume]    Script Date: 06/12/2012 17:46:21 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_JobsResume_Resume]') AND parent_object_id = OBJECT_ID(N'[dbo].[JobsResume]'))
ALTER TABLE [dbo].[JobsResume]  WITH CHECK ADD  CONSTRAINT [FK_JobsResume_Resume] FOREIGN KEY([ResumeId])
REFERENCES [dbo].[Resume] ([ResumeId])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_JobsResume_Resume]') AND parent_object_id = OBJECT_ID(N'[dbo].[JobsResume]'))
ALTER TABLE [dbo].[JobsResume] CHECK CONSTRAINT [FK_JobsResume_Resume]
GO
/****** Object:  ForeignKey [FK_Company_inherits_Person]    Script Date: 06/12/2012 17:46:21 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Company_inherits_Person]') AND parent_object_id = OBJECT_ID(N'[dbo].[Person_Company]'))
ALTER TABLE [dbo].[Person_Company]  WITH CHECK ADD  CONSTRAINT [FK_Company_inherits_Person] FOREIGN KEY([PersonId])
REFERENCES [dbo].[Person] ([PersonId])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Company_inherits_Person]') AND parent_object_id = OBJECT_ID(N'[dbo].[Person_Company]'))
ALTER TABLE [dbo].[Person_Company] CHECK CONSTRAINT [FK_Company_inherits_Person]
GO
/****** Object:  ForeignKey [FK_JobSeeker_inherits_Person]    Script Date: 06/12/2012 17:46:21 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_JobSeeker_inherits_Person]') AND parent_object_id = OBJECT_ID(N'[dbo].[Person_JobSeeker]'))
ALTER TABLE [dbo].[Person_JobSeeker]  WITH CHECK ADD  CONSTRAINT [FK_JobSeeker_inherits_Person] FOREIGN KEY([PersonId])
REFERENCES [dbo].[Person] ([PersonId])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_JobSeeker_inherits_Person]') AND parent_object_id = OBJECT_ID(N'[dbo].[Person_JobSeeker]'))
ALTER TABLE [dbo].[Person_JobSeeker] CHECK CONSTRAINT [FK_JobSeeker_inherits_Person]
GO
/****** Object:  ForeignKey [FK_Resume_JobSeeker]    Script Date: 06/12/2012 17:46:21 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Resume_JobSeeker]') AND parent_object_id = OBJECT_ID(N'[dbo].[Resume]'))
ALTER TABLE [dbo].[Resume]  WITH CHECK ADD  CONSTRAINT [FK_Resume_JobSeeker] FOREIGN KEY([JobSeekerId])
REFERENCES [dbo].[Person_JobSeeker] ([PersonId])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Resume_JobSeeker]') AND parent_object_id = OBJECT_ID(N'[dbo].[Resume]'))
ALTER TABLE [dbo].[Resume] CHECK CONSTRAINT [FK_Resume_JobSeeker]
GO
/****** Object:  ForeignKey [FK_Security_Person]    Script Date: 06/12/2012 17:46:21 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Security_Person]') AND parent_object_id = OBJECT_ID(N'[dbo].[Security]'))
ALTER TABLE [dbo].[Security]  WITH CHECK ADD  CONSTRAINT [FK_Security_Person] FOREIGN KEY([PersonId])
REFERENCES [dbo].[Person] ([PersonId])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Security_Person]') AND parent_object_id = OBJECT_ID(N'[dbo].[Security]'))
ALTER TABLE [dbo].[Security] CHECK CONSTRAINT [FK_Security_Person]
GO
